<?php
class Model_ExpertsDomainMap extends Model{

	function save($uid, $domainIds){
		if(!is_array($domainIds)) {
			return false;
		}
		$uid = intval($uid);
		$this->removeByCondition("where uid = '$uid'");
		
		foreach ($domainIds as $did){
			$data['did'] = $did;
			$data['uid'] = $uid;
			$this->insert($data);
			
		}
		
		return count($domainIds);
	}
	
	function getDomainsByUser($uid){
		$data = $this->select('did',"where uid = '$uid'");
		foreach ($data as &$row){
			$row = $row['did'];
		}
		return $data;
	}
}
?>